/*
 * @Author: yao
 * @Date: 2024-11-12 09:47:58
 * @LastEditTime: 2024-11-19 15:10:54
 * @LastEditors: yao
 * @Description:
 * @FilePath: \jdev-web\src\utils\http.ts
 */

// 请求参数包裹参数
export const setRequestParam = (
  data: object,
  otherData?: object | null,
  modId = ""
) => {
  return {
    requester: "",
    modId: modId,
    args: data,
    ...otherData,
  };
};

/**
 *
 * @param url 解析url
 * @returns
 */
export const getParams = (url: any) => {
  try {
    const keyValueArr = url.split("?")[1].split("&");
    let paramObj: any = {};
    keyValueArr.forEach((item: string) => {
      const keyValue = item.split("=");
      paramObj[keyValue[0]] = keyValue[1];
    });
    return paramObj;
  } catch {
    return "";
  }
};
